package com.yantong.constant;

import java.util.*;

/**
 * 优惠券类型
 *
 * @author kanghaixin
 * @date 2018/9/25.14:01
 */
public enum TicketType {
	VOUCHER(1, "抵扣券"),
	COUPON(2, "折扣券"),
	PINKAGE(3, "包邮券"),
	SINGLE_COUPON(4, "单品抵扣券"),
	CAMILO(5, "卡密券"),
	//JUHEPAY(6, "扫码支付赠送"),
	;

	private int code;
	private String name;


	private static Map<Integer, String> all = new HashMap<>();

	static {
		for (TicketType ticketType : EnumSet.allOf(TicketType.class)) {
			all.put(ticketType.code, ticketType.name);
		}
	}

	public static String get(Integer code) {
		return all.get(code);
	}


	public static List<Map<String, Object>> listTicketTypes() {
		List<Map<String, Object>> list = new ArrayList<>();

		for (TicketType ticketType : EnumSet.allOf(TicketType.class)) {
			Map<String, Object> item = new HashMap<>();
			item.put("code", ticketType.getCode());
			item.put("name", ticketType.getName());
			list.add(item);
		}
		return list;
	}

	TicketType(int code, String name) {
		this.code = code;
		this.name = name;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
}
